import axios from 'axios'

const _axios = axios.create({
  baseURL: process.env.VUE_APP_URL
})

_axios.interceptors.request.use(
  config => {
    return config
  },
  error => {
    return Promise, reject(error)
  }
)
_axios.interceptors.response.use(
  res => {
    return res.data
  },
  error => {
    return Promise, reject(error)
  }
)
function ajax (url, method = 'GET', params) {
  return _axios({
    url,
    method,
    [method.toLowerCase() === 'get' ? params : data]: params
  })
}

export default _axios
// export default ajax
